#ifndef OBJECTMANAGER_H
#define OBJECTMANAGER_H
#include "PoolAllocator.h"
class GameObject;

struct ObjectNode
{
	ObjectNode* next;
	ObjectNode* previous;
	GameObject* obj;
};
typedef void (_cdecl *objectFunc)(GameObject* obj);

class ObjectManager
{
public:
	ObjectManager(void);
	~ObjectManager(void);

	void* Add(GameObject& obj);
	bool Remove(long long objID);
	bool RemoveAll(void);

	void PerformOperationOnAllObjects(objectFunc func);

	GameObject* FindObject(long long objectID) const;
	ObjectNode* GetFirstObject(void) const;
	ObjectNode* GetLastObject(void) const;
	int GetCount(void) const;

	void PrintObjects(void) const;

private:

	bool DeleteObject(ObjectNode* obj);

	PoolAllocator m_allocator;
	ObjectNode* m_firstObject;
	ObjectNode* m_lastObject;
	int			m_count;
};

#endif